import { CellRenderer } from "../../../../fl/controls/listClasses/CellRenderer";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { EffectManager } from "../../manager/EffectManager";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { FairylandCellData } from "./FairylandCellData";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GButton } from "../../../../com/mui/controls/GButton";
//class FairylandCellRenderer
    
    export  class FairylandCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.init();
            this.mouseChildren = true;
            return;
        }

        /* internal  */init(): void
        {
            this.initStyle();
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            this._bg = GlobalClass.getBitmap("Friend_over");
            this._bg.width = 100;
            this.addChild(this._bg);
            this._icon = GlobalClass.getBitmap(ImagesConst.fairylandIcon);
            this.addChild(this._icon);
            this._tfName = ObjCreate.createTextField(Language.getString(42607), 20, 3, 60, 20, this, GlobalStyle.textFormat6);
            this._tfPeopleNum = ObjCreate.createTextField("", 100, 3, 50, 20, this);
            this._btnJoin = ObjCreate.createGButton(Language.getString(42608), 160, 2, 55, 20, this);
            this._btnJoin.drawNow();
            return;
        }

        /* internal  */setJoinBtnFilter(arg1: Boolean): void
        {
            if (arg1) 
            {
                EffectManager.glowFilterReg(this._btnJoin, [FilterConst.chatTipsFilter], 0.6, 10, 1);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._btnJoin);
            }
            return;
        }

        /* internal  */addListeners(): void
        {
            this._btnJoin.addEventListener(flash.events.MouseEvent.CLICK, this.onJoinHandler);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "fairylandcelldata") 
            {
                this._failylandData = arg1 as FairylandCellData;
                this.updateView();
                this.drawNow();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            if (this._failylandData.index < FairylandCellRenderer.Namelist.length) 
            {
                this._tfName.text = FairylandCellRenderer.Namelist[this._failylandData.index];
            }
            this._tfPeopleNum.text = this._failylandData.fairyland.num + "/" + this._failylandData.fairyland.maxNum;
            this.setJoinBtnFilter(this._failylandData.fairyland.isCaptainIn);
            return;
        }

        /* internal  */onJoinHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.FairylandEnter, this._failylandData.fairyland.fairylandId));
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_icon: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfPeopleNum: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnJoin: GButton;

        /* internal */ /* var */_failylandData: FairylandCellData;

        /* internal */ static /* var */Namelist: Array<any>;
    }

            FairylandCellRenderer.Namelist = Language.getString(42606).split(",");
        